package com.ninong.ker.common.tools;

import java.util.regex.Pattern;

public class ValidUitl {
	
	/**
	 * 两位小数金额校验
	 * @param obj
	 * @return
	 */
    public static boolean judgeTwoDecimal(Object obj) {
        boolean flag = false;
        try {
            if (obj != null) {
                String source = obj.toString();
                // 判断是否是整数或者是携带一位或者两位的小数
                Pattern pattern = Pattern.compile("^[+]?([0-9]+(.[0-9]{1,2})?)$");
                if (pattern.matcher(source).matches()) {
                    flag = true;
                }
            }
        } catch (Exception e) {
            e.getMessage();
        }
        return flag;
    }
    

	/**
	 * 手机号校验
	 * @param obj
	 * @return
	 */
    public static boolean phone(Object obj) {
        boolean flag = false;
        try {
            if (obj != null) {
                String source = obj.toString();
                // 验证手机号码为11位，且以1开头
                Pattern pattern = Pattern.compile("^1[0-9]{10}$");
                if (pattern.matcher(source).matches()) {
                    flag = true;
                }
            }
        } catch (Exception e) {
            e.getMessage();
        }
        return flag;
    }

}
